<%@ page import="com.javaee.interceptor.entity.Shopping_Cart" %>
<%@ page import="java.util.List" %>
<%@ page import="static com.javaee.my.user.BaseControllerApi.sqlsession" %><%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2021/11/21
  Time: 18:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="refresh" content="1">
    <title>购物车</title>
</head>
<%
    HttpSession sessions = request.getSession();
    Integer id= (Integer) session.getAttribute("id");
    //查询用户购物车中的商品以及其最终总价格
    List<Shopping_Cart> Shopping_Cartlist=sqlsession.selectList(
            "com.javaee.my.dao.businessMapper.select_Shopping_cartBy_id",id);
    Float finalAllPrice=sqlsession.selectOne("com.javaee.my.dao.businessMapper.select_Shopping_cart_allprice",id);
    if (finalAllPrice==null)
    {
        finalAllPrice=0f;
    }
    System.out.println(finalAllPrice);
%>
<body>
<table border=1>
    <tr>
        <td> 商品编号</td>
        <td> 商品购买数量</td>
        <td> 商品最终总价格</td>
    </tr>
    <%
        for (int i = 0; i < Shopping_Cartlist.size(); i++){
    %>
    <tr>
        <td><%=Shopping_Cartlist.get(i).getGoods_id()%></td>
        <td><%=Shopping_Cartlist.get(i).getNums()%></td>
        <td><%=Shopping_Cartlist.get(i).getAllprice()%></td>
    </tr>
    <%
        }
    %>
    <p>商品最终总价格：<%=finalAllPrice%></p>
</table>
</body>
</html>
